<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 38 </title>
    <style>
        div {
            font-size: 66px;
        }
    </style>
    <script src="https://unpkg.com/vue@next"></script>

</head>
<body>
<div id="root"></div>
</body>
<script>

    // computed 计算属性
    const app = Vue.createApp({
        setup(props, context) {
            const { ref, computed} = Vue;
            const count = ref(0)
            const handleClick = ()=>{
                count.value +=1;
            }
           /* const countAddFive =computed( ()=>{
                return count.value + 5;
            })*/

            const countAddFive =computed({
                get: ()=> {
                 return count.value + 5;
                },

                set: (params)=> {
                    count.value = params -5;
                },
            })

            setTimeout(()=>{
                countAddFive.value = 100;
            },2000)

            return {
                count,
                countAddFive,
                handleClick,
            }
        },

        // created 实例被完全初始化之前
        template: `
          <div @click="handleClick">
            {{count}} ——{{countAddFive}}
          </div>
        `
    });



    const vm = app.mount('#root');
</script>
</html>